/* GUI CONVERTED from rspomtb.p (converter v1.76) Mon Jul 22 11:49:54 2002 */
/* rspomtb.p - Release Management Scheduled Order Maintenance Sub Program     */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.49 $                                                          */
/* REVISION: 7.3    LAST MODIFIED: 09/30/92           BY: WUG *G462*          */
/* REVISION: 7.3    LAST MODIFIED: 05/24/93           BY: WUG *GB29*          */
/* REVISION: 7.3    LAST MODIFIED: 06/01/93           BY: WUG *GB46*          */
/* REVISION: 7.3    LAST MODIFIED: 06/07/93           BY: WUG *GB75*          */
/* REVISION: 7.3    LAST MODIFIED: 06/16/93           BY: WUG *GC34*          */
/* REVISION: 7.3    LAST MODIFIED: 07/07/93           BY: WUG *GD20*          */
/* REVISION: 7.3    LAST MODIFIED: 07/13/93           BY: WUG *GD42*          */
/* REVISION: 7.3    LAST MODIFIED: 07/13/93           BY: WUG *GD43*          */
/* REVISION: 7.4    LAST MODIFIED: 08/06/94           BY: bcm *H057*          */
/* REVISION: 7.3    LAST MODIFIED: 04/21/94           BY: WUG *GJ48*          */
/* REVISION: 7.3    LAST MODIFIED: 05/16/94           BY: WUG *GJ59*          */
/* REVISION: 7.3    LAST MODIFIED: 09/26/94           BY: ljm *GM77*          */
/* REVISION: 7.3    LAST MODIFIED: 10/24/94           BY: ljm *GN54*          */
/* REVISION: 7.3    LAST MODIFIED: 10/31/94           BY: WUG *GN76*          */
/* REVISION: 7.3    LAST MODIFIED: 11/11/94           BY: dpm *GO13*          */
/* REVISION: 8.5    LAST MODIFIED: 11/21/94           BY: mwd *J034*          */
/* REVISION: 7.3    LAST MODIFIED: 01/17/95           by: srk *G0C1*          */
/* REVISION: 7.3    LAST MODIFIED: 01/31/95           by: srk *H09T*          */
/* REVISION: 7.4    LAST MODIFIED: 02/06/95           BY: rxm *G0DH*          */
/* REVISION: 7.4    LAST MODIFIED: 02/16/95           by: rxm *G0D5*          */
/* REVISION: 7.5    LAST MODIFIED: 02/21/95           BY: dpm *J044*          */
/* REVISION: 7.4    LAST MODIFIED: 02/23/95           by: jzw *H0BM*          */
/* REVISION: 7.4    LAST MODIFIED: 03/02/95           by: rxm *G0G5*          */
/* REVISION: 7.4    LAST MODIFIED: 03/29/95           by: dzn *F0PN*          */
/* REVISION: 7.4    LAST MODIFIED: 03/29/95           by: pmf *G0JR*          */
/* REVISION: 7.4    LAST MODIFIED: 05/15/95           by: vrn *G0MW*          */
/* REVISION: 7.4    LAST MODIFIED: 05/19/95           by: dxk *G0N7*          */
/* REVISION: 7.4    LAST MODIFIED: 05/23/95           by: vrn *G0NC*          */
/* REVISION: 7.4    LAST MODIFIED: 06/07/95           by: dxk *G0PF*          */
/* REVISION: 7.4    LAST MODIFIED: 07/06/95           by: vrn *G0RV*          */
/* REVISION: 7.4    LAST MODIFIED: 08/01/95           by: dxk *G0T5*          */
/* REVISION: 7.4    LAST MODIFIED: 01/08/96           by: kjm *G1JC*          */
/* REVISION: 7.4    LAST MODIFIED: 02/02/96           by: kjm *G1LT*          */
/* REVISION: 8.5    LAST MODIFIED: 02/26/96       BY: *J0CV* Brandy J Ewing   */
/* REVISION: 8.5    LAST MODIFIED: 03/29/96       BY: BHolmes *J0FY*          */
/* REVISION: 8.5    LAST MODIFIED: 04/08/96       by: dxk *G1R3*              */
/* REVISION: 8.5    LAST MODIFIED: 04/23/96       BY: rpw *J0K4*              */
/* REVISION: 8.5    LAST MODIFIED: 04/23/96       BY: rpw *J0K4*              */
/* REVISION: 8.5    LAST MODIFIED: 06/10/96       BY: rxm *G1XN*              */
/* REVISION: 8.5    LAST MODIFIED: 07/08/96       BY: ajw *J0SZ*              */
/* REVISION: 8.5    LAST MODIFIED: 08/20/96       BY: *G2CP* Suresh Nayak     */
/* REVISION: 8.5    LAST MODIFIED: 12/05/96       BY: *H0PP* Ajit Deodhar     */
/* REVISION: 8.5    LAST MODIFIED: 01/09/97       BY: *J1B1* Robin McCarthy   */
/* REVISION: 8.5    LAST MODIFIED: 02/14/97       BY: *G2L2* Jim Williams     */
/* REVISION: 8.5    LAST MODIFIED: 03/03/97       BY: *H0T4* Aruna Patil      */
/* REVISION: 8.5    LAST MODIFIED: 05/08/97       BY: *J1QW* Suresh Nayak     */
/* REVISION: 8.5    LAST MODIFIED: 06/02/97       BY: *H0ZB* Ajit Deodhar     */
/* REVISION: 8.5    LAST MODIFIED: 06/16/97       BY: *J1T5* Suresh Nayak     */
/* REVISION: 8.5    LAST MODIFIED: 07/23/97       BY: *H1CC* Aruna Patil      */
/* REVISION: 8.5    LAST MODIFIED: 09/04/97       BY: *G2PD* Nirav Parikh     */
/* REVISION: 8.5    LAST MODIFIED: 11/26/97       BY: *J271* Aruna Patil      */
/* REVISION: 8.5    LAST MODIFIED: 12/02/97       BY: *J274* Seema Varma      */
/* REVISION: 8.5    LAST MODIFIED: 02/05/98       BY: *J2DN* Seema Varma      */
/* REVISION: 8.6    LAST MODIFIED: 05/20/98       BY: *K1Q4* Alfred Tan       */
/* REVISION: 8.6E   LAST MODIFIED: 06/11/98       BY: *L040* Charles Yen      */
/* REVISION: 8.6E   LAST MODIFIED: 08/17/98       BY: *L062* Steve Nugent     */
/* REVISION: 8.6E   LAST MODIFIED: 11/12/98       BY: *J30M* Seema Varma      */
/* REVISION: 9.0    LAST MODIFIED: 12/01/98       BY: *K1QY* Suresh Nayak     */
/* REVISION: 9.0    LAST MODIFIED: 03/13/99       BY: *M0BD* Alfred Tan       */
/* REVISION: 9.1    LAST MODIFIED: 10/01/99       BY: *N014* Patti Gaultney   */
/* REVISION: 9.1    LAST MODIFIED: 08/20/99       BY: *J3KX* J. Fernando      */
/* REVISION: 9.1    LAST MODIFIED: 01/19/00       BY: *N077* Vijaya Pakala    */
/* REVISION: 9.1    LAST MODIFIED: 02/02/00       BY: *N07K* Pat Pigatti      */
/* REVISION: 9.1    LAST MODIFIED: 03/24/00       BY: *N08T* Annasaheb Rahane */
/* REVISION: 9.1    LAST MODIFIED: 08/12/00       BY: *N0KP* Mark Brown       */
/* REVISION: 9.1    LAST MODIFIED: 12/21/00       BY: *N0V9* Jyoti Thatte     */
/* Revision: 1.36        BY: Katie Hilbert        DATE: 04/01/01  ECO: *P002* */
/* Revision: 1.37        BY: Niranjan Ranka       DATE: 07/13/01  ECO: *P00L* */
/* Revision: 1.38        BY: Rajaneesh Sarangi    DATE: 12/17/01  ECO: *M1SC* */
/* Revision: 1.39        BY: Jean Miller          DATE: 04/17/02  ECO: *P05L* */
/* Revision: 1.40        BY: Patrick Rowan        DATE: 05/24/02  ECO: *P018* */
/* Revision: 1.41        BY: Tiziana Giustozzi    DATE: 05/24/02  ECO: *P03Z* */
/* Revision: 1.42        BY: Jean Miller          DATE: 06/07/02  ECO: *P080* */
/* Revision: 1.43        BY: Kirti Desai          DATE: 06/11/02  ECO: *N1L2* */
/* Revision: 1.44        BY: R.Satya Narayan      DATE: 06/25/02  ECO: *P086* */
/* Revision: 1.48        BY: Kirti Desai          DATE: 07/05/02  ECO: *N1NC* */
/* $Revision: 1.49 $     BY: Robin McCarthy       DATE: 07/15/02  ECO: *P0BJ* */

/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/
/*V8:ConvertMode=Maintenance                                                  */

{mfdeclre.i}
{gplabel.i}    /* EXTERNAL LABEL INCLUDE */
{pxmaint.i}
{apconsdf.i}   /* PRE-PROCESSOR CONSTANTS FOR LOGISTICS ACCOUNTING */

define input parameter po_recid    as recid.
define input parameter consignment as logical.

define shared frame po.
define shared frame po1.
define shared frame pod.
define shared frame pod1.
define shared frame pod2.

define new shared variable global_curr  as   character.
define new shared variable global_order as   character.
define new shared variable new_site     like si_site.
define new shared variable err_stat     as   integer.
define new shared variable so_db        like dc_name.
define new shared variable any_msgs     as   logical.

define shared variable tax_in  like ad_tax_in.
define shared variable cmtindx like cmt_indx.
define shared variable impexp  like mfc_logical no-undo.

define variable line              as   integer        no-undo.
define variable yn                like mfc_logical.
define variable new-pod           like mfc_logical.
define variable erslst            like ers_pr_lst_tp  no-undo.
define variable ers-err           as   integer        no-undo.
define variable ersopt            like ers_opt        no-undo.
define variable del-yn            like mfc_logical.
define variable scx_recid         as   recid          no-undo.
define variable valid_acct        like mfc_logical.
define variable zone_to           like txz_tax_zone   no-undo.
define variable zone_from         like txz_tax_zone   no-undo.
define variable old_pod_site      like pod_site       no-undo.
define variable schedule_found    like mfc_logical.
define variable somrp_found       as   logical        no-undo.
define variable err-flag          as   integer        no-undo.
define variable old_db            like si_db          no-undo.
define variable found_price       like mfc_logical.
define variable save_supp_part    like vp_vend_part   no-undo.
define variable i                 as   integer        no-undo.
define variable counter           as   integer        no-undo.
define variable ptstatus          like pt_status      no-undo.
define variable newline           as   integer        no-undo.
define variable shipper_found     as   integer        no-undo.
define variable save_abs          like abs_par_id     no-undo.
define variable l_continue        like mfc_logical    no-undo.
define variable mc-error-number   like msg_nbr        no-undo.
define variable l_deactivate      like mfc_logical    no-undo.
define variable l_pod_um_conv     like pod_um_conv    no-undo.
define variable imp-okay          like mfc_logical    no-undo.
define variable subtype           as   character format "x(12)"
   label "Subcontract Type" no-undo.
define variable l_adg_module      as   logical   initial false no-undo.
define variable l_blank           as   character initial ""    no-undo.
define variable use-log-acctg     as   logical                 no-undo.
define variable purcost           like pod_pur_cost            no-undo.
define variable unitcost          like pod_pur_cost            no-undo.

/* Consignment variables */
{pocnvars.i}
/* Consignment procedures and frames */
{pocnpo.i}

{rsordfrm.i}
/* DECLARATIONS FOR gptxcval.i */
{gptxcdec.i}

/* TAX ENVIRONMENT FORM */
FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
pod_tax_usage     colon 25
   pod_tax_env       colon 25
   pod_tax_in        colon 25
 SKIP(.4)  /*GUI*/
with frame set_tax row 8 overlay centered side-labels attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-set_tax-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame set_tax = F-set_tax-title.
 RECT-FRAME-LABEL:HIDDEN in frame set_tax = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame set_tax =
  FRAME set_tax:HEIGHT-PIXELS - RECT-FRAME:Y in frame set_tax - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME set_tax = FRAME set_tax:WIDTH-CHARS - .5.  /*GUI*/


/* SET EXTERNAL LABELS */
setFrameLabels(frame set_tax:handle).

using_supplier_consignment = consignment.

for first poc_ctrl
   fields(poc_ers_proc poc_hcmmts poc_insp_loc poc_lcmmts)
   no-lock:
end. /* FOR FIRST poc_ctrl */

for first icc_ctrl
   fields(icc_cur_cost icc_cur_set icc_gl_set)
   no-lock:
end. /* FOR FIRST icc_ctrl */

/* VALIDATE IF LOGISTICS ACCOUNTING IS TURNED ON */
{gprun.i ""lactrl.p"" "(output use-log-acctg)"}
/*GUI*/ if global-beam-me-up then undo, leave.


pocmmts = poc_hcmmts.

run readpo_mstr(input  po_recid,
                buffer po_mstr).

run readvd_mstr(input  po_vend,
                buffer vd_mstr).

run readad_mstr (input  po_vend,
                 buffer ad_mstr).

assign
   global_order = po_nbr
   global_addr  = po_vend.

clear frame pod  no-pause.
/*GUI*/ RECT-FRAME-LABEL:SCREEN-VALUE in frame pod = F-pod-title.
clear frame pod1 no-pause.
/*GUI*/ RECT-FRAME-LABEL:SCREEN-VALUE in frame pod1 = F-pod1-title.
clear frame pod2 no-pause.
/*GUI*/ RECT-FRAME-LABEL:SCREEN-VALUE in frame pod2 = F-pod2-title.

detailloop:
repeat:
/*GUI*/ if global-beam-me-up then undo, leave.

   hide frame pod1 no-pause.
   hide frame pod2 no-pause.

   /* FIND OR CREATE DETAIL RECORD */

   save_supp_part = "".

   do with frame pod:

      prompt-for
         scx_part
         scx_shipto
         scx_line
      editing:
         if frame-field = "scx_part"
         then do:

            /* REPLACED "INPUT SCX_PART" TO "INPUT FRAME POD SCX_PART" */
            {mfnp05.i scx_ref scx_po "scx_type = 2
             and scx_po = po_nbr"
               scx_part "input frame pod scx_part"}

            if recno <> ?
            then do:

               run readpt_mstr (input  scx_part,
                                buffer pt_mstr).

               run readpod_det (input  po_nbr,
                                input  scx_line,
                                buffer pod_det).

               run readsi_mstr (input  scx_shipto,
                                buffer si_mstr).

               global_site = pod_site.

               display
                  scx_part
                  scx_shipto
                  si_desc
                  pod_vpart
                  scx_line.

                  if pod_vpart = ""
                  then
                     display
                        pt_desc1 @ pod_vpart
                        pt_desc2 @ pt_desc1.
                  else
                     display
                        pt_desc1 @ pt_desc1.
            end. /* IF recno <> ? */
         end. /* IF frame-field = "scx_part" */

         else
         if frame-field = "scx_shipto"
         then do:

            /* REPLACED "INPUT SCX_PART" TO "INPUT FRAME POD SCX_PART"
            AND "INPUT SCX_SHIPTO" TO "INPUT FRAME POD SCX_SHIPTO" */
            {mfnp05.i scx_ref scx_po "scx_type = 2
               and scx_po = po_nbr and
               scx_part = input frame pod scx_part"
               scx_shipto "input frame pod scx_shipto"}

            if recno <> ?
            then do:

               run readpt_mstr (input  scx_part,
                                buffer pt_mstr).

               run readpod_det (input  po_nbr,
                                input  scx_line,
                                buffer pod_det).

               run readsi_mstr (input  scx_shipto,
                                buffer si_mstr).

               global_site = pod_site.

               display
                  scx_part
                  scx_shipto
                  si_desc
                  pod_vpart
                  scx_line.

                  if pod_vpart = ""
                  then
                     display
                        pt_desc1 @ pod_vpart
                        pt_desc2 @ pt_desc1.
                  else
                     display
                        pt_desc1 @ pt_desc1.
            end. /* IF recno <> ? */
         end. /* IF frame-field = "scx_shipto" */

         else
         if frame-field = "scx_line"
         then do:
            {mfnp05.i scx_ref scx_order "scx_type = 2
               and scx_order = po_nbr"
               scx_line "input frame pod scx_line"}

            if recno <> ?
            then do:

               run readpt_mstr (input  scx_part,
                                buffer pt_mstr).

               run readpod_det (input  po_nbr,
                                input  scx_line,
                                buffer pod_det).

               run readsi_mstr (input  scx_shipto,
                                buffer si_mstr).

               global_site = pod_site.

               display
                  scx_part
                  scx_shipto
                  si_desc
                  pod_vpart
                  scx_line.
                  if pod_vpart = ""
                  then
                     display
                        pt_desc1 @ pod_vpart
                        pt_desc2 @ pt_desc1.
                  else
                     display
                        pt_desc1 @ pt_desc1.
            end. /* IF recno <> ? */

         end. /* IF frame-field = "scx_line" */
         else do:
            status input.
            readkey.
            apply lastkey.
         end. /* ELSE DO */
      end. /* EDITING */

      if frame pod scx_line entered
      and input frame pod scx_line = 0
      then do:
         /* INVALID LINE NUMBER */
         run display_message_mfmsg03
            (input 642,
             input 4,
             input l_blank,
             input l_blank,
             input l_blank,
             input l_blank,
             input l_blank).
         undo, retry.
      end. /* IF FRAME pod scx_line ENTERED... */

      /* REPLACED "scx_part" TO "frame pod scx_part" */
      if frame pod scx_line entered
      and not frame pod scx_part entered
      then do:

         run readpod_det (input  po_nbr,
                          input  input frame pod scx_line,
                          buffer pod_det).

         if available pod_det
         then do:
            global_site = pod_site.

            display
               pod_part @ scx_part
               pod_site @ scx_shipto.
         end. /* IF AVAILABLE pod_det */
      end. /* IF FRAME pod scx_line ENTERED */

      run readpt_mstr (input  frame pod scx_part,
                       buffer pt_mstr).

      if not available pt_mstr
      then do:

         if can-find(first vp_mstr
            where vp_vend_part = input frame pod scx_part
              and vp_vend = (if po_vend <> ""
                             then
                                po_vend
                             else
                                ""))
         then do:

            for each vp_mstr
               fields(vp_part vp_q_date vp_vend vp_vend_part)
               where vp_vend_part = input frame pod scx_part
               and vp_vend = po_vend
               no-lock
               break by vp_q_date descending:

               if first(vp_q_date)
               then do:

                  run readpt_mstr (input  vp_part,
                                   buffer pt_mstr).

                  if available pt_mstr
                  then do:

                     save_supp_part = input frame pod scx_part.

                     display
                        pt_part @ scx_part
                        with frame pod.

                     /* SUPPLIER ITEM x REPLACED BY ITEM y */
                     run display_message_mfmsg03
                        (input 371,
                         input 1,
                         input vp_vend_part,
                         input vp_part,
                         input l_blank,
                         input l_blank,
                         input l_blank).
                  end. /* IF available pt_mstr */
                  else do:
                     /* ITEM NUMBER DOES NOT EXIST */
                     run display_message_mfmsg03
                        (input 16,
                         input 3,
                         input l_blank,
                         input l_blank,
                         input l_blank,
                         input l_blank,
                         input l_blank).
                     undo, retry.
                  end. /* ELSE DO */

               end. /* IF FIRST(vp_q_date) */

            end. /* FOR EACH vp_mstr */

         end. /* IF CAN-FIND(FIRST vp_mstr */

         else do:
            /* ITEM NUMBER DOES NOT EXIST */
            run display_message_mfmsg03
               (input 16,
                input 3,
                input l_blank,
                input l_blank,
                input l_blank,
                input l_blank,
                input l_blank).
            undo, retry.
         end. /* ELSE DO */

      end. /* IF NOT AVAILABLE pt_mstr */

      /* INITIALIZE SUPPLIER ITEM IF AVAILABLE */
      else do:
         if can-find(first vp_mstr
            where vp_part = input frame pod scx_part
              and vp_vend = (if po_vend <> ""
                             then
                                po_vend
                             else
                                ""))
         then do:

            for each vp_mstr
               fields(vp_part vp_q_date vp_vend vp_vend_part)
               where vp_part = input frame pod scx_part
               and vp_vend = po_vend
               no-lock
               break by vp_q_date descending:

               if first(vp_q_date)
               then do:
                  save_supp_part = vp_vend_part.
                  leave.
               end. /* IF FIRST vp_q_date */

            end. /* FOR EACH vp_mstr */

         end. /* IF CAN-FIND FIRST vp_mstr */

      end. /* ELSE OF IF NOT AVAILABLE pt_mstr */

      /*  CHECK TO SEE WHETHER THE PART IS RESTRICTED FROM THE
          BEING USED IN A PO - CODE COPIED FROM popomte.p. */
      assign
         ptstatus                = pt_status.
         substring(ptstatus,9,1) = "#".

      if can-find(isd_det
         where isd_status = ptstatus
         and isd_tr_type = "ADD-PO")
      then do:
         /* RESTRICTED PROCEDURE FOR ITEM STATUS CODE XXX */
         run display_message_mfmsg03
            (input 358,
             input 3,
             input pt_status,
             input l_blank,
             input l_blank,
             input l_blank,
             input l_blank).
         undo, retry.
      end. /* IF CAN-FIND(isd_det */

      global_part = input frame pod scx_part.

      run readsi_mstr (input  input frame pod scx_shipto,
                       buffer si_mstr).

      if not available si_mstr
      then do:
         /* SITE DOES NOT EXIST */
         run display_message_mfmsg03
            (input 708,
             input 3,
             input l_blank,
             input l_blank,
             input l_blank,
             input l_blank,
             input l_blank).
         undo, retry.
      end. /* IF NOT AVAILABLE si_mstr */

      {gprun.i ""gpsiver.p""
         "(input  si_site,
           input  recid(si_mstr),
           output return_int)"}
/*GUI*/ if global-beam-me-up then undo, leave.


      if return_int = 0
      then do:
         /* USER DOES NOT HAVE ACCESS TO SITE */
         run display_message_mfmsg03
            (input 725,
             input 3,
             input l_blank,
             input l_blank,
             input l_blank,
             input l_blank,
             input l_blank).
         undo, retry.
      end. /* IF return_int = 0 */

      for first ptp_det
         fields(ptp_ins_rqd ptp_part ptp_pm_code ptp_site)
         where ptp_part = pt_part
         and ptp_site = si_site
         no-lock:
      end. /* FOR FIRST ptp_det */

      if (available ptp_det
      and (ptp_pm_code = "C"
      or ptp_pm_code = "F"))
      then do:

         /* ITEM PUR/MFG CODE IS # */
         run display_message_mfmsg03
            (input 1850,
             input 2,
             input ptp_pm_code,
             input l_blank,
             input l_blank,
             input l_blank,
             input l_blank).
      end. /* IF (AVAILABLE ptp_det */

      else
      if (not available ptp_det
         and (pt_pm_code = "F"
         or pt_pm_code = "C"))
      then do:
         /* ITEM PUR/MFG CODE IS # */
         run display_message_mfmsg03
            (input 1850,
             input 2,
             input pt_pm_code,
             input l_blank,
             input l_blank,
             input l_blank,
             input l_blank).
      end. /* IF (NOT AVAILABLE ptp_det */

      for first scx_ref
         fields(scx_line scx_order scx_part scx_po scx_shipfrom scx_shipto
                scx_type)
         where scx_type = 2
         and scx_shipfrom = po_vend
         and scx_shipto = input frame pod scx_shipto
         and scx_part = input frame pod scx_part
         and scx_po = po_nbr
         no-lock:
      end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* FOR FIRST scx_ref */

      if not available scx_ref
      then do:

         /* LOGIC TO WRAP AROUND IF THE LINE# LIMIT IS REACHED AND TO
            SEEK ANY UNUSED LINE NUMBER. CODE COMPLEMENTS THE FUNCTIONALITY
            OF ARCHIVE/DELETE OF SCHEDULE LINE*/
         for last pod_det
            fields(pod_acct pod_cc pod_cmtindx pod_consignment
                   pod_cst_up pod_cum_date pod_cum_qty pod_curr_rlse_id
                   pod_end_eff pod_ers_opt pod_fab_days pod_firm_days
                   pod_insp_rqd pod_line pod_loc pod_max_aging_days
                   pod_nbr pod_op pod_ord_mult pod_part pod_pkg_code
                   pod_plan_days pod_plan_mths pod_plan_weeks pod_po_db
                   pod_po_site pod_pr_list pod_pr_lst_tp pod_pst
                   pod_pur_cost pod_raw_days pod_rev pod_sched
                   pod_sched_chgd pod_sd_pat pod_sftylt_days pod_site
                   pod_start_eff pod_sub pod_taxable pod_taxc pod_tax_env
                   pod_tax_in pod_tax_usage pod_translt_days pod_type
                   pod_um pod_um_conv pod_vpart pod_wo_lot pod__qad16)
            where pod_nbr = po_nbr
            no-lock:
         end. /* FOR LAST pod_det */

         line = 1.
         /* SCREENS & REPORTS DON'T SUPPORT 4 DIGIT LINE NOS. */
         if available pod_det
         then do:

            if pod_line < 999
            then
               line = pod_line + 1.
            else
               if pod_line = 999
               then do:

                  /*  MAX LINE# USED, SEARCH FOR NEXT AVAILABLE LINE# */
                  run display_message_mfmsg03
                     (input 6025,
                      input 1,
                      input l_blank,
                      input l_blank,
                      input l_blank,
                      input l_blank,
                      input l_blank).

                  pause 1 no-message.
                  do counter = 1 to 999:
                     display
                        counter @ scx_line.
                     if not can-find (scx_ref
                        where scx_type = 2
                        and scx_order = po_nbr
                        and scx_line  = counter)
                        then do:

                        line = counter.
                        leave.
                     end. /* IF NOT CAN-FIND (scx_ref */
                  end. /* DO counter = 1 TO 999 */

                  if counter = 1000
                  then do:
                     /* ALL AVAILABLE LINE# ARE USED */
                     run display_message_mfmsg03
                        (input 6026,
                         input 4,
                         input l_blank,
                         input l_blank,
                         input l_blank,
                         input l_blank,
                         input l_blank).
                     undo, retry.
                  end. /* IF counter = 1000 */

               end.  /* IF pod_line = 999  */
         end.  /* IF AVAILABLE pod_det */

         /* ADDING NEW RECORD */
         run display_message_mfmsg03
            (input 1,
             input 1,
             input l_blank,
             input l_blank,
             input l_blank,
             input l_blank,
             input l_blank).

         create scx_ref.
         assign
            scx_type     = 2
            scx_shipfrom = po_vend
            scx_shipto   = input frame pod scx_shipto
            scx_part     = input frame pod scx_part
            scx_po       = po_nbr
            scx_order    = po_nbr.

         /* IF USER ENTERED LINE NUMBER IT'S OK IF IT'S UNUSED */
         if frame pod scx_line entered
         and line <> input frame pod scx_line
         then do:

            newline = input frame pod scx_line.

            if not can-find (scx_ref where scx_type = 2 and
                                           scx_order = po_nbr and
                                           scx_line = newline) and
               not can-find (pod_det where pod_nbr = po_nbr
                                       and pod_line = newline)
            then
               line = newline.

         end. /* IF FRAME pod scx_line ENTERED */

         display
            line @ scx_line.

         create pod_det.
         assign
            scx_line        = line
            new-pod         = yes
            pod_nbr         = po_nbr
            pod_line        = scx_line
            pod_part        = scx_part
            pod_site        = scx_shipto
            pod_sched       = yes
            pod_taxable     = (po_taxable and pt_taxable)
            pod_tax_usage   = po_tax_usage
            pod_tax_in      = tax_in
            pod_taxc        = pt_taxc
            pod_pst         = po_pst
            pod_po_db       = global_db
            pod_um          = pt_um
            pod_um_conv     = 1
            pod_ord_mult    = 1
            pod_acct        = vd_pur_acct
            pod_sub         = vd_pur_sub
            pod_cc          = vd_pur_cc
            pod_rev         = pt_rev
            pod_insp_rqd    = if available ptp_det
                              then
                                 ptp_ins_rqd
                              else
                                 pt_insp_rqd
            pod_loc         = if pod_insp_rqd
                              then
                                 poc_insp_loc
                              else
                                 pt_loc
            pod_cum_date[1] = today
            pod_vpart       = save_supp_part
            pod__qad16      = subtype
            pod_pr_list     = vd_pr_list.


         if recid(pod_det) = -1 then .

         /* DETERMINE CONSIGNMENT SETTINGS */
         if using_supplier_consignment
         then do:
            {pxrun.i &PROC = 'initializeSuppConsignDetailFields'
                     &PARAM="(input po_vend,
                              input pod_part,
                              input po_consignment,
                              input po_max_aging_days,
                              output pod_consignment,
                              output pod_max_aging_days)"}
         end.  /* IF using_supplier_consignment */

         /* KEEP TAX ENV. BLANK TO INVOKE SUGGESTION OF TAX ENV. */

         i = 0.
         for each si_mstr
            fields(si_db si_desc si_site)
            no-lock
            where si_site >= "":
            i = i + 1.
            if i >= 2
            then
               leave.
         end. /* FOR EACH si_mstr */

         if pod_site = po_site
         then
            pod_po_site = po_site.
         else
         if po_site <> ""
         then
            pod_po_site = po_site.
         else
         if not can-find(si_mstr
            where si_site = "")
         then
            pod_po_site = pod_site.
         else
         if i >= 2
         then
            pod_po_site = pod_site.

         if icc_cur_cost = "NONE"
         then
            pod_cst_up = no.
         else
            pod_cst_up = yes.

         {gpsct05.i &part=pod_part &site=pod_site &cost=sct_mtl_tl}
         pod_pur_cost = glxcst.

         /* CONVERT FROM BASE TO FOREIGN CURRENCY */
         {gprunp.i "mcpl" "p" "mc-curr-conv"
                "(input base_curr,
                  input po_curr,
                  input po_ex_rate2,
                  input po_ex_rate,
                  input pod_pur_cost,
                  input false, /* DO NOT ROUND */
                  output pod_pur_cost,
                  output mc-error-number)"}.

         if use-log-acctg
            and po_tot_terms_code <> ""
         then do:

            if po_curr = base_curr
             and pod_pur_cost = glxcst
            then do:

               /* UPDATE LOGISTICS ACCOUNTING TERMS OF TRADE FIELD */
               {gprunmo.i &module = "LA" &program = "lapopr.p"
                          &param  = """(input pod_um,
                                        input glxcst,
                                        input po_nbr,
                                        input pod_part,
                                        input pod_site,
                                        output pod_pur_cost)"""}

            end. /* IF po_curr = base_curr */

            else if po_curr <> base_curr
            then do:

              /* CONVERT FROM BASE TO FOREIGN CURRENCY */
               {gprunp.i "mcpl" "p" "mc-curr-conv"
                  "(input base_curr,
                   input po_curr,
                   input po_ex_rate2,
                   input po_ex_rate,
                   input glxcst,
                   input false, /* DO NOT ROUND */
                   output unitcost,
                   output mc-error-number)"}.

               if unitcost = pod_pur_cost
               then do:

                  /* UPDATE LOGISTICS ACCOUNTING TERMS OF TRADE FIELD */
                  {gprunmo.i &module="LA" &program="lapopr.p"
                     &param="""(input pod_um,
                                input glxcst,
                                input po_nbr,
                                input pod_part,
                                input pod_site,
                                output purcost)"""}

                  /* CONVERT FROM BASE TO FOREIGN CURRENCY */
                  {gprunp.i "mcpl" "p" "mc-curr-conv"
                     "(input base_curr,
                      input po_curr,
                      input po_ex_rate2,
                      input po_ex_rate,
                      input purcost,
                      input false, /* DO NOT ROUND */
                      output pod_pur_cost,
                      output mc-error-number)"}.

               end. /* IF unitcost = pod_pur_cost */

            end. /* IF po_curr <> base_curr */

         end. /* IF use-log-acctg */

         for first pl_mstr
            fields(pl_prod_line)
            where pl_prod_line = pt_prod_line
            no-lock:
         end. /* FOR FIRST pl_mstr */

         if available pl_mstr
         then do:
            {gprun.i ""glactdft.p""
               "(input ""PO_PUR_ACCT"",
                 input pt_prod_line,
                 input pod_site,
                 input if available vd_mstr
                       then
                          vd_type
                       else
                          """",
                 input """",
                 input no,
                 output pod_acct,
                 output pod_sub,
                 output pod_cc)"}
/*GUI*/ if global-beam-me-up then undo, leave.

         end. /* IF AVAILABLE pl_mstr */

         yn = yes.

         /* COPY DATA FROM ANOTHER ORDER LINE FOR THIS ITEM? */
         run display_message_mfmsg01
            (input        8231,
             input        1,
             input-output yn).

         if yn
         then do:
            {gprun.i ""rspomta.p"" "(input recid(pod_det))"}
/*GUI*/ if global-beam-me-up then undo, leave.

         end. /* IF yn */
      end. /* IF NOT available scx_ref */
      else do:
         find pod_det where pod_nbr = scx_order
            and pod_line = scx_line exclusive-lock.
         new-pod = no.
      end. /* ELSE DO */

      assign
         new_site    = pod_site
         global_part = pt_part
         so_db       = global_db.

      {gprun.i ""gpptsi01.p""}
/*GUI*/ if global-beam-me-up then undo, leave.


      if err_stat > 1
      then do:
         /* ITEM DOES NOT EXIST AT THIS SITE */
         run display_message_mfmsg03
            (input 715,
             input 3,
             input l_blank,
             input l_blank,
             input l_blank,
             input l_blank,
             input l_blank).
         undo, retry.
      end. /* IF err_stat > 1 */

      display
         scx_part
         pod_vpart
         scx_line.

      if pod_vpart = ""
      then
         display
            pt_desc1 @ pod_vpart
            pt_desc2 @ pt_desc1.
      else
         display
            pt_desc1 @ pt_desc1.

   end. /* DO WITH FRAME pod */

   subtype = pod__qad16.

   /* DETAIL DATA ITEMS FRAME 1 */
   display
      pod_pr_list
      pod_pur_cost
      pod_acct
      pod_sub
      pod_cc
      pod_taxable
      pod_taxc
      pod_type
      pod_cst_up
      pod_loc
      pod_um
      pod_um_conv
      pod_wo_lot
      pod_consignment
      pod_op
      subtype
   with frame pod1.

   do with frame pod1 on error undo, retry:
/*GUI*/ if global-beam-me-up then undo, leave.

      ststatus = stline[2].
      status input ststatus.

      assign
         global_part = pod_part
         global_curr = po_curr.

      set
         pod_pr_list
         pod_pur_cost
         pod_acct
         pod_sub
         pod_cc
         pod_taxable
         pod_taxc
         pod_type
         pod_consignment when (using_supplier_consignment)
         pod_cst_up
         pod_loc
         pod_um
      go-on("F5" "CTRL-D").

      del-yn = no.
      if lastkey = keycode("F5")
      or lastkey = keycode("CTRL-D")
      then do:
         del-yn = yes.
         /* PLEASE CONFIRM DELETE */
         run display_message_mfmsg01
            (input        11,
             input        1,
             input-output del-yn).

         if not del-yn then undo, retry.
      end. /* IF lastkey = keycode("F5") */

      if del-yn
      then do:

         shipper_found = 0.

         {gprun.i ""rsschck.p""
            "(input  pod_nbr,
              input  pod_line,
              input  scx_part,
              input  scx_shipto,
              output schedule_found,
              output somrp_found,
              output shipper_found,
              output save_abs)"}
/*GUI*/ if global-beam-me-up then undo, leave.


         if schedule_found
         then do:
            /* SCHEDULE EXISTS, DELETE NOT ALLOWED */
            run display_message_mfmsg03
               (input 6022,
                input 3,
                input l_blank,
                input l_blank,
                input l_blank,
                input l_blank,
                input l_blank).
            undo, retry.
         end. /* IF schedule_found */

         if somrp_found
         then do:
            /* USED IN SCHEDULED ORDER MRP % TABLE */
            run display_message_mfmsg03
               (input 6027,
                input 4,
                input l_blank,
                input l_blank,
                input l_blank,
                input l_blank,
                input l_blank).
            undo, retry.
         end. /* IF somrp_found */

         if shipper_found >= 1
         then do:

            save_abs = substring(save_abs,2,12).
            /* # SHIPPERS/CONTAINERS EXIST FOR ORDER, INCLUDING #" */
            run display_message_mfmsg03
               (input 1118,
                input 2,
                input shipper_found,
                input save_abs,
                input l_blank,
                input l_blank,
                input l_blank).

            /* PLEASE CONFIRM DELETE */
            run display_message_mfmsg01
               (input        11,
                input        1,
                input-output del-yn).

            if not del-yn
            then
               undo, retry.
         end. /* IF shipper_found >= 1 */

         for first prh_hist
            fields(prh_line prh_nbr)
            where prh_nbr = pod_nbr
            and prh_line = pod_line
            no-lock:
         end. /* FOR FIRST prh_hist */

         if available prh_hist
         then do:

            /* DELETE NOT ALLOWED, PO LINE HAS RECEIPTS */
            run display_message_mfmsg03
               (input 364,
                input 4,
                input l_blank,
                input l_blank,
                input l_blank,
                input l_blank,
                input l_blank).
            undo, retry.
         end. /* IF AVAILABLE prh_hist THEN */

         {gprun.i ""rssddel.p"" "(input recid(pod_det))"}
/*GUI*/ if global-beam-me-up then undo, leave.


         hide frame pod1.

         clear frame pod no-pause.
/*GUI*/ RECT-FRAME-LABEL:SCREEN-VALUE in frame pod = F-pod-title.
         next detailloop.

      end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* IF del-yn */

      if pod_pr_list <> ""
      then do:

         found_price = no.

         /* Validate that the Price List exists using the current date instead
            of the Scheduled Order Date since these orders can be added to
            over long periods of time.  To use the Scheduled Order Date
            would mean that pricing list Effective Dates would have to be
            backdated to the date the order was originally entered.  This
            is not only impractical but could also lead to other problems.
            NB: Prior to patch G013, no date limitation existed. This patch
            only changes validation.  The actual pricing assignment
            occurs during scheduled shipper confirmation (receipt) and uses
            the Effective Date specified at that time.  */

         {gprun.i ""rcpccal1.p""
            "(input  pod_part,
              input  pod_pr_list,
              input  today,
              input  pod_um,
              input  po_curr,
              output found_price)"}
/*GUI*/ if global-beam-me-up then undo, leave.


         if found_price  = false
         then do:

            l_continue = yes.
            /* DISCOUNT TABLE NOT FOUND.  CONTINUE */
            run display_message_mfmsg01
               (input        6203,
                input        2,
                input-output l_continue).

            if not l_continue
            then do:
               next-prompt
                  pod_pr_list.
               undo, retry.
            end. /* IF NOT l_continue */
         end. /* IF found_price  = false */
      end. /* IF pod_pr_list <> "" */

      /* INITIALIZE SETTINGS */
      {gprunp.i "gpglvpl" "p" "initialize"}

      /* SET PROJECT VERIFICATION TO NO */
      {gprunp.i "gpglvpl" "p" "set_proj_ver" "(input false)"}

      /* ACCT/SUB/CC VALIDATION */
      {gprunp.i "gpglvpl" "p" "validate_fullcode"
         "(input  pod_acct,
           input  pod_sub,
           input  pod_cc,
           input  """",
           output valid_acct)"}

      if valid_acct = no
      then do:
         next-prompt
            pod_acct
         with frame pod1.
         undo, retry.
      end. /* IF valid_acct = no */

      if not (pod_type = ""
      or pod_type = "s")
      then do:
         /* INVALID TYPE CODE */
         run display_message_mfmsg03
            (input 4211,
             input 3,
             input l_blank,
             input l_blank,
             input l_blank,
             input l_blank,
             input l_blank).
         next-prompt pod_type.
         undo, retry.
      end. /* IF NOT (pod_type = "" */

      /* VALIDATE TAX CODE */
      {gptxcval.i &code=pod_taxc &frame="pod1"}

      /* GET TAX MANAGEMENT DATA */
      if pod_taxable
      then do:

         taxloop:
         do on error undo, retry:
/*GUI*/ if global-beam-me-up then undo, leave.


            /* SUGGEST TAX ENVIRONMENT */
            if pod_tax_env = ""
            then do:

               /* GET VENDOR SHIP_FROM TAX ZONE FROM ADDRESS */
               run readad_mstr (input  vd_addr,
                                buffer ad_mstr).

               if available ad_mstr
               then
                  zone_from = ad_tax_zone.

               /* GET SHIP_TO TAX ZONE FROM SHIP TO ADDRESS */
               run readad_mstr (input  scx_shipto,
                                buffer ad_mstr).

               if available ad_mstr
               then
                  zone_to = ad_tax_zone.

               if not available ad_mstr
               then do:
                  /* SITE ADDRESS DOES NOT EXIST */
                  run display_message_mfmsg03
                     (input 864,
                      input 2,
                      input l_blank,
                      input l_blank,
                      input l_blank,
                      input l_blank,
                      input l_blank).
                  zone_to = "".
               end. /* IF NOT  AVAILABLE ad_mstr */

               /* SUGGEST A TAX ENVIRONMENT */
               /* REPLACED pod_taxc WITH po_taxc */
               {gprun.i ""txtxeget.p""
                  "(input zone_to,
                    input zone_from,
                    input po_taxc,
                    output pod_tax_env)"}
/*GUI*/ if global-beam-me-up then undo, leave.

            end. /* IF pod_tax_env = "" */

            update
               pod_tax_usage
               pod_tax_env
               pod_tax_in
            with frame set_tax.

            /* VALIDATE TAX ENVIRONMENT -- BLANKS NOT ALLOWED */
            if pod_tax_env = ""
            then do:
               /* BLANK TAX ENVIRONMENT NOT ALLOWED */
               run display_message_mfmsg03
                  (input 944,
                   input 3,
                   input l_blank,
                   input l_blank,
                   input l_blank,
                   input l_blank,
                   input l_blank).
               next-prompt pod_tax_env with frame set_tax.
               undo taxloop, retry.
            end.  /* IF pod_tax_env = "" */

            if not {gptxe.v "pod_tax_env" ""no""}
            then do:
               /* TAX ENVIRONMENT DOES NOT EXIST */
               run display_message_mfmsg03
                  (input 869,
                   input 3,
                   input l_blank,
                   input l_blank,
                   input l_blank,
                   input l_blank,
                   input l_blank).
               next-prompt pod_tax_env with frame set_tax.
               undo taxloop, retry.
            end.  /* IF NOT gptxe.v */

            hide frame set_tax.

         end.
/*GUI*/ if global-beam-me-up then undo, leave.
  /* taxloop */

      end. /* IF pod_taxable */

      if not pod_taxable
      and pod_tax_env = ""
      then
         pod_tax_env = po_tax_env.

      l_pod_um_conv = pod_um_conv.

      if pt_um <> pod_um
      then do:

         /* CHECK FOR CONVERSION */
         run check_um_mstr (input        pt_um,
                            input        pod_um,
                            input        pod_part,
                            input-output pod_um_conv).

      end. /* IF pt_um <> pod_um */

      /*No F5/Delete Available */
      ststatus = stline[3].
      status input ststatus.

      update
         pod_um_conv
         with frame pod1.

      if l_pod_um_conv  <> pod_um_conv
      then
         run p-conv-cost
            (input-output pod_pur_cost,
             input        l_pod_um_conv,
             input        pod_um_conv).

      if can-find (first ie_mstr
         where ie_type = "2"
         and ie_nbr =  pod_nbr)
      then do:
         imp-okay = no.
         {gprun.i ""iedetcr.p""
            "(input ""2"",
              input pod_nbr,
              input pod_line,
              input recid(pod_det),
              input-output imp-okay)"}
/*GUI*/ if global-beam-me-up then undo, leave.

         if imp-okay = no
         then
            undo , retry.
      end. /* IF CAN-FIND (FIRST ie_mstr */

      /* DETERMINE RIGHT NOW WHAT THE VALID OPTIONS ARE */
      {gprun.i ""poers.p""
         "(input po_vend,
           input pod_site,
           input pod_part,
           output ersopt,
           output erslst,
           output ers-err)"}
/*GUI*/ if global-beam-me-up then undo, leave.


      /* DETERMINE PROPER DEFAULT VALUES */
      if new-pod
      then do:
         if po_ers_opt = ""
         then
            assign
               pod_ers_opt = ersopt
               pod_pr_lst_tp = (if po_pr_lst_tp = 0
                                then
                                   erslst
                                else
                                   po_pr_lst_tp).
         else
            assign
               pod_ers_opt = integer(po_ers_opt)
               pod_pr_lst_tp = po_pr_lst_tp.
      end. /* IF NEW-POD */

      /* UPDATE ERS FIELDS ONLY IF ERS IS ENABLED */
      if available poc_ctrl
      and poc_ers_proc
      then do:

         ers-loop:
         do with frame poders on error undo, retry:
/*GUI*/ if global-beam-me-up then undo, leave.


            /* SET EXTERNAL LABELS */
            setFrameLabels(frame poders:handle).

            display
               pod_ers_opt   colon 23 skip
               pod_pr_lst_tp colon 23 space(1)
            with frame poders centered side-labels no-attr-space overlay
            row (frame-row(pod1) + 3).

            set
               pod_ers_opt
               pod_pr_lst_tp
            with frame poders.

            /* VALIDATE ERS OPTION ENTERED IS VALID */
            if not({gppoders.v})
            then do:
               /* INVALID ERS OPTION */
               run display_message_mfmsg03
                  (input 2303,
                   input 3,
                   input l_blank,
                   input l_blank,
                   input l_blank,
                   input l_blank,
                   input l_blank).
               next-prompt
                  pod_ers_opt.
               undo, retry ers-loop.
            end. /* IF NOT({gppoders.v}) */

            /* VERIFY THAT ENTERED VALUE OF ERS OPTION ISN'T TOO HIGH */
            if pod_ers_opt entered
            then do:
               if ers-err = 0
               and pod_ers_opt > ersopt
               then do:

                  /*ERS OPTION NOT VALID BASED UPON SUPPLIER/SITE/ITEM*/
                  run display_message_mfmsg03
                     (input 2317,
                      input 1,
                      input l_blank,
                      input l_blank,
                      input l_blank,
                      input l_blank,
                      input l_blank).

                  /* ERS OPTION MUST BE LESS THAN OR EQUAL TO */
                  run display_message_mfmsg03
                     (input 2318,
                      input 3,
                      input string(ersopt),
                      input l_blank,
                      input l_blank,
                      input l_blank,
                      input l_blank).

                  next-prompt
                     pod_ers_opt.
                  undo, retry ers-loop.
               end.  /* IF ERS-ERR = 0 */

               else
               if ers-err = 1
               then do:
                  /* ERS VALUES MISSING FOR SITE */
                  run display_message_mfmsg03
                     (input 2311,
                      input 2,
                      input l_blank,
                      input l_blank,
                      input l_blank,
                      input l_blank,
                      input l_blank).
                  /* ERS OPTION SET TO 1 */
                  run display_message_mfmsg03
                     (input 2346,
                      input 1,
                      input l_blank,
                      input l_blank,
                      input l_blank,
                      input l_blank,
                      input l_blank).
                  pod_ers_opt = 1.
                  display
                     pod_ers_opt
                     with frame poders.
                  next-prompt
                     pod_ers_opt.
                  undo, retry ers-loop.
               end. /* IF ers-err = 1 */

               else
               if ers-err = 2
               then do:

                  /* ERS VALUES MISSING FOR SUPPLIER */
                  run display_message_mfmsg03
                     (input 2309,
                      input 2,
                      input l_blank,
                      input l_blank,
                      input l_blank,
                      input l_blank,
                      input l_blank).

                  /* ERS OPTION SET TO 1 */
                  run display_message_mfmsg03
                     (input 2346,
                      input 1,
                      input l_blank,
                      input l_blank,
                      input l_blank,
                      input l_blank,
                      input l_blank).

                  pod_ers_opt = 1.
                  display
                     pod_ers_opt
                     with frame poders.
                  next-prompt
                     pod_ers_opt.
                  undo, retry ers-loop.
               end. /* IF ers-err = 2 */

               else
               if ers-err = 3
               then do:

                  /* ERS VALUES MISSING FOR SUPPLIER AND SITE */
                  run display_message_mfmsg03
                     (input 2301,
                      input 2,
                      input l_blank,
                      input l_blank,
                      input l_blank,
                      input l_blank,
                      input l_blank).

                  /* ERS OPTION SET TO 1 */
                  run display_message_mfmsg03
                     (input 2346,
                      input 1,
                      input l_blank,
                      input l_blank,
                      input l_blank,
                      input l_blank,
                      input l_blank).

                  pod_ers_opt = 1.
                  display
                     pod_ers_opt
                     with frame poders.
                  next-prompt
                     pod_ers_opt.
                  undo, retry ers-loop.
               end. /* IF ers-err = 3 */
            end. /* IF POD_ERS_OPT ENTERED */

         end.
/*GUI*/ if global-beam-me-up then undo, leave.
  /* ERS-LOOP */

         hide frame poders.

      end.   /* IF AVAIL POC_CTRL */

      if pod_type <> "x"
      and pod__qad16 = ?
      then
         pod__qad16 = "".

      if pod_type = "s"
      then do:

         run readsi_mstr (input  pod_site,
                          buffer si_mstr).

         old_db = global_db.
         if si_db <> global_db
         then do:
            {gprun.i ""gpalias3.p"" "(si_db, output err-flag)" }
/*GUI*/ if global-beam-me-up then undo, leave.

         end. /* IF si_db <> global_db */

         {gprun.i ""rspomtb1.p""
            "(input        pod_site,
              input-output pod_wo_lot,
              input-output pod_op,
              input-output subtype)"}
/*GUI*/ if global-beam-me-up then undo, leave.


         pod__qad16 = subtype.

         if old_db <> global_db
         then do:
            {gprun.i ""gpalias3.p"" "(old_db, output err-flag)" }
/*GUI*/ if global-beam-me-up then undo, leave.

         end. /* IF old_db <> global_db */

         if keyfunction(lastkey) = "END-ERROR"
         then
            undo,retry.

      end. /* IF pod_type = "s" */

      else
         /*Only hide frame pod1 if not type "s" since
         rspomtb1.p (for subcontract items) will also
         use pod1.  If we hide it then reuse it, the
         frame will flash. */
         hide frame pod1.

   end. /* DO WITH FRAME pod1 */

   /* The flag on the control file rsc_ctrl and mfc_ctrl would always
   be maintained in sync. So we test value of mfc_ctrl flag */

   l_adg_module = no.

   if can-find (first mfc_ctrl
      where mfc_field = "enable_shipping_schedules"
      and mfc_seq = 4
      and mfc_module = "ADG"
      and mfc_logical = yes)
   then
      l_adg_module = yes.

   if l_adg_module
   then do:

      /* DEFAULT VALUES IN LINE ITEM DATA FIELDS FROM SUPPLIER */
      /* IF VALUES IN SUPPLIER MASTER ARE BLANK THEN DEFAULT   */
      /* FROM SCHEDULE CONTROL FILE                            */
      {gprunmo.i &module="ASH" &program="rspomtb2.p"
         &param="""(input recid(pod_det),
                    input new-pod)"""}

   end. /* IF l_adg_module */

   if using_supplier_consignment
   and pod_consignment
   then do:
      {pxrun.i &PROC='setAgingDays'
               &PARAM="(input-output pod_max_aging_days)"}

      hide frame aging.
   end. /* IF using_supplier_consignment */

   /* DETAIL DATA ITEMS FRAME 2 */
   podcmmts = (pod_cmtindx <> 0 or (new pod_det and poc_lcmmts)).

   display
      pod_firm_days
      pod_plan_days
      pod_plan_weeks
      pod_plan_mths
      pod_fab_days
      pod_raw_days
      pod_translt_days
      pod_sftylt_days
      pod_vpart
      pod_pkg_code
      pod_sd_pat
      pod_cum_qty[3]
      pod_ord_mult
      pod_cum_date[1]
      podcmmts
      pod_start_eff[1]
      pod_end_eff[1]
   with frame pod2.

   do with frame pod2 on error undo, retry:
/*GUI*/ if global-beam-me-up then undo, leave.


      ststatus = stline[3].
      status input ststatus.

      set
         pod_firm_days
         pod_plan_days
         pod_plan_weeks
         pod_plan_mths
         pod_fab_days
         pod_raw_days
         pod_translt_days
         pod_sftylt_days
         pod_vpart
         pod_pkg_code
         pod_sd_pat
         pod_cum_qty[3]
         pod_ord_mult
         pod_cum_date[1]
         podcmmts
         pod_start_eff[1]
         pod_end_eff[1].

      l_deactivate = no.
      if pod_pkg_code <> ""
      then do:

         run readpt_mstr (input  pod_pkg_code,
                          buffer pt_mstr).

         if not available pt_mstr
         then do:
            /*ITEM NUMBER DOES NOT EXIST*/
            run display_message_mfmsg03
               (input 16,
                input 3,
                input l_blank,
                input l_blank,
                input l_blank,
                input l_blank,
                input l_blank).
            next-prompt
               pod_pkg_code
               with frame pod2.
            undo, retry.
         end. /* IF NOT AVAILABLE pt_mstr */
      end. /* IF pod_pkg_code <> "" */

      if pod_firm_days entered
      and pod_curr_rlse_id[1] <> ""
      then do:
         /* ACTIVE SCHEDULE EXISTS. PLANNED DATA MAY NOT BE */
         /* CARRIED FORWARD                                 */
         run display_message_mfmsg03
            (input 2360,
             input 2,
             input l_blank,
             input l_blank,
             input l_blank,
             input l_blank,
             input l_blank).

         /* DEACTIVATE ACTIVE SCHEDULE? - YES/NO            */
         run display_message_mfmsg01
            (input        2361,
             input        1,
             input-output l_deactivate).

         if l_deactivate
         then do:
            pod_curr_rlse_id[1] = "".
            for each mrp_det exclusive-lock
                  where mrp_dataset = "ss sch_mstr"
                  and mrp_part    = pod_part
                  and mrp_nbr     = pod_nbr
                  and mrp_line    = string(pod_line):
               delete mrp_det.
            end. /* FOR EACH mrp_det */
         end. /* IF l_deactivate */
      end.  /* IF pod_firm_days ENTERED */

      if pod_ord_mult = 0
      then do:
         /* ZERO NOT ALLOWED */
         run display_message_mfmsg03
            (input 317,
             input 3,
             input l_blank,
             input l_blank,
             input l_blank,
             input l_blank,
             input l_blank).
         next-prompt
            pod_ord_mult.
         undo, retry.
      end. /* IF pod_ord_mult = 0 */

      if pod_vpart <> ""
         and not can-find(vp_mstr
         where vp_vend_part = pod_vpart
         and vp_part = pod_part
         and vp_vend = po_vend)
      then do:
         /* SUPPLIER ITEM DOES NOT EXIST */
         run display_message_mfmsg03
            (input 238,
             input 3,
             input l_blank,
             input l_blank,
             input l_blank,
             input l_blank,
             input l_blank).
         next-prompt pod_vpart.
         undo, retry.
      end. /* IF pod_vpart <> "" */

      if not ({gpcode.v pod_sd_pat sch_sd_pat})
      then do:
         /* VALUE MUST EXIST IN GENERALIZED CODES */
         run display_message_mfmsg03
            (input 716,
             input 3,
             input l_blank,
             input l_blank,
             input l_blank,
             input l_blank,
             input l_blank).
         next-prompt
            pod_sd_pat.
         undo, retry.
      end. /* IF NOT ({gpcode.v pod_sd_pat sch_sd_pat}) */

      if pod_cum_qty[3] = 0
         and can-find(whl_mstr
         where whl_mstr.whl_site = pod_site
         and whl_mstr.whl_loc = pod_loc
         and whl_mstr.whl_act)
      then do:
         /* MAX ORDER QTY CANNOT = 0 WHEN RCV'G INTO EXTERNAL WHSE */
         run display_message_mfmsg03
            (input 1811,
             input 3,
             input l_blank,
             input l_blank,
             input l_blank,
             input l_blank,
             input l_blank).
         next-prompt
            pod_cum_qty[3].
         undo, retry.
      end. /* IF pod_cum_qty[3] = 0 */

      /* POP-UP WINDOW TO ALLOW USERS TO SPECIFY CREATION OF A
         SHIPPING SCHEDULE AND USAGE OF AN SDT CODE */
      if l_adg_module
      then do:
         {gprunmo.i &module="ASH" &program="rspomtb4.p"
            &param="""(input recid(pod_det))"""}

         /* ROUTINE TO DO ALL THE VALIDATIONS IF SUPPLIER */
         /* SHIPPING SCHEDULES IS INSTALLED               */
         {gprunmo.i &module="ASH" &program="rspomtb3.p"
            &param="""(input recid(pod_det))"""}

         if return-value = "pod_plan_days"
         then do:
            next-prompt
               pod_plan_days
            with frame pod2.
            undo, retry.
         end. /* IF return-value = "pod_plan_days" */
         else
         if return-value = "pod_plan_weeks"
         then do:
            next-prompt
               pod_plan_weeks
            with frame pod2.
            undo, retry.
         end. /* IF return-value = "pod_plan_weeks" */
         else
         if return-value = "pod_plan_mths"
         then do:
            next-prompt
               pod_plan_mths
            with frame pod2.
            undo, retry.
         end. /* IF return-value = "pod_plan_mths" */
      end. /* IF l_adg_module */
      hide frame pod2.
   end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* DO WITH FRAME pod2 */

   /* DETAIL COMMENTS */
   if podcmmts
   then do:
      assign
         cmtindx    = pod_cmtindx
         global_ref = pod_part.
      {gprun.i ""gpcmmt01.p"" "(input ""pod_det"")"}
/*GUI*/ if global-beam-me-up then undo, leave.

      pod_cmtindx = cmtindx.

      view frame po.
   end. /* IF podcmmts */

   {gprun.i ""rsrsdup.p"" "(input recid(pod_det))"}
/*GUI*/ if global-beam-me-up then undo, leave.


   pod_sched_chgd = yes.
   release pod_det.

   if recid(scx_ref) = -1 then .
   release scx_ref.

end. /* REPEAT */

PROCEDURE p-conv-cost:

   define input-output parameter l_pod_pur_cost like pod_pur_cost no-undo.
   define input        parameter l_pod_um_conv  like pod_um_conv  no-undo.
   define input        parameter l_pod_um_conv1 like pod_um_conv  no-undo.

   /* UM CHANGED; CONVERT UNIT COST TO ALTERNATE UM? */
   run display_message_mfmsg01
      (input        2783,
       input        1,
       input-output yn).

   if yn
   then
      l_pod_pur_cost = l_pod_pur_cost / l_pod_um_conv * l_pod_um_conv1.

END PROCEDURE. /* p-conv-cost */

PROCEDURE display_message_mfmsg03:

   define input parameter l_msg_nbr   as integer    no-undo.
   define input parameter l_msg_level as integer    no-undo.
   define input parameter l_parm_1    as character  no-undo.
   define input parameter l_parm_2    as character  no-undo.
   define input parameter l_parm_3    as character  no-undo.
   define input parameter l_parm_4    as character  no-undo.
   define input parameter l_parm_5    as character  no-undo.

   {pxmsg.i &MSGNUM=l_msg_nbr &ERRORLEVEL=l_msg_level
            &MSGARG1=l_parm_1
            &MSGARG2=l_parm_2
            &MSGARG3=l_parm_3
            &MSGARG4=l_parm_4
            &MSGARG5=l_parm_5}

END PROCEDURE. /* display_message_mfmsg03 */

PROCEDURE readpt_mstr:

   /* TO AVOID ACTION SEGMENT ERROR MOVED THE CODE FOR RECORD */
   /* FIND IN INTERNAL PROCEDURE                              */

   define input parameter l_pt_part like pt_part no-undo.

   define parameter buffer pt_mstr for pt_mstr .

   for first pt_mstr
      fields(pt_desc1 pt_desc2 pt_insp_rqd pt_loc pt_part
             pt_pm_code pt_prod_line pt_rev pt_status pt_taxable
             pt_taxc pt_um)
      where pt_part = l_pt_part
      no-lock:
   end. /* FOR FIRST pt_mstr */

END PROCEDURE. /* readpt_mstr */

PROCEDURE readpod_det:

   /* TO AVOID ACTION SEGMENT ERROR MOVED THE CODE FOR RECORD */
   /* FIND IN INTERNAL PROCEDURE                              */

   define input parameter l_pod_nbr  like pod_nbr  no-undo.
   define input parameter l_pod_line like pod_line no-undo.

   define parameter buffer pod_det for pod_det .

   for first pod_det
      fields(pod_acct pod_cc pod_cmtindx pod_consignment
             pod_cst_up pod_cum_date pod_cum_qty pod_curr_rlse_id
             pod_end_eff pod_ers_opt pod_fab_days pod_firm_days
             pod_insp_rqd pod_line pod_loc pod_max_aging_days
             pod_nbr pod_op pod_ord_mult pod_part pod_pkg_code
             pod_plan_days pod_plan_mths pod_plan_weeks pod_po_db
             pod_po_site pod_pr_list pod_pr_lst_tp pod_pst
             pod_pur_cost pod_raw_days pod_rev pod_sched
             pod_sched_chgd pod_sd_pat pod_sftylt_days pod_site
             pod_start_eff pod_sub pod_taxable pod_taxc pod_tax_env
             pod_tax_in pod_tax_usage pod_translt_days pod_type
             pod_um pod_um_conv pod_vpart pod_wo_lot pod__qad16)
      where pod_nbr  = l_pod_nbr
      and   pod_line = l_pod_line
      no-lock:
   end. /* FOR FIRST pod_det */

END PROCEDURE. /* readpod_det */

PROCEDURE readsi_mstr:

   /* TO AVOID ACTION SEGMENT ERROR MOVED THE CODE FOR RECORD */
   /* FIND IN INTERNAL PROCEDURE                              */

   define input parameter l_si_site like si_site  no-undo.

   define parameter buffer si_mstr for si_mstr .

   for first si_mstr
      fields(si_db si_desc si_site)
      where si_site = l_si_site
      no-lock:
   end. /* FOR FIRST si_mstr */

END PROCEDURE. /* readsi_mstr */

PROCEDURE readad_mstr:

   /* TO AVOID ACTION SEGMENT ERROR MOVED THE CODE FOR RECORD */
   /* FIND IN INTERNAL PROCEDURE                              */

   define input parameter l_ad_addr like ad_addr  no-undo.

   define parameter buffer ad_mstr for ad_mstr .

   for first ad_mstr
      fields(ad_addr ad_name ad_tax_zone)
      where ad_addr = l_ad_addr
      no-lock:
   end. /* FOR FIRST ad_mstr */

END PROCEDURE. /* readad_mstr */

PROCEDURE check_um_mstr:

   /* TO AVOID ACTION SEGMENT ERROR MOVED THE CODE FOR RECORD */
   /* FIND IN INTERNAL PROCEDURE                              */

   define input        parameter l_um_um       like um_um       no-undo.
   define input        parameter l_um_alt_um   like um_alt_um   no-undo.
   define input        parameter l_um_part     like um_part     no-undo.
   define input-output parameter l_pod_um_conv like pod_um_conv no-undo.

   for first um_mstr
      fields(um_alt_um um_conv um_part um_um)
      where um_um     = l_um_um
      and   um_alt_um = l_um_alt_um
      and   um_part   = l_um_part
      no-lock:
   end. /* FOR FIRST um_mstr */

   if not available um_mstr
   then
      for first um_mstr
         fields(um_alt_um um_conv um_part um_um)
         where um_um     = l_um_um
         and   um_alt_um = l_um_alt_um
         and   um_part   = ""
         no-lock:
         l_pod_um_conv = um_conv.
      end. /* FOR FIRST um_mstr */

   if not available um_mstr
   then do:
      /* NO UM CONVERSION EXISTS */
      run display_message_mfmsg03
         (input 33,
          input 2,
          input l_blank,
          input l_blank,
          input l_blank,
          input l_blank,
          input l_blank).
   end. /* IF NOT AVAILABLE um_mstr */

END PROCEDURE. /* check_um_mstr */

PROCEDURE readpo_mstr:

   /* TO AVOID ACTION SEGMENT ERROR MOVED THE CODE FOR RECORD */
   /* FIND IN INTERNAL PROCEDURE                              */

   define input parameter l_po_recid as recid no-undo.

   define parameter buffer po_mstr for po_mstr.

   for first po_mstr
      fields(po_ap_acct po_ap_cc po_ap_sub po_bill po_buyer po_consignment
             po_contact po_contract po_cr_terms po_curr po_ers_opt po_ex_rate
             po_ex_rate2 po_fob po_max_aging_days po_nbr po_pr_lst_tp po_pst
             po_ship po_shipvia po_site po_taxable po_taxc po_tax_usage
             po_tot_terms_code po_vend)
      where recid(po_mstr) = l_po_recid
      no-lock:
   end. /* FOR FIRST po_mstr */

END PROCEDURE. /* readpo_mstr */

PROCEDURE readvd_mstr:

   /* TO AVOID ACTION SEGMENT ERROR MOVED THE CODE FOR RECORD */
   /* FIND IN INTERNAL PROCEDURE                              */

   define input parameter l_vd_addr like vd_addr no-undo.

   define parameter buffer vd_mstr for vd_mstr.

   for first vd_mstr
      fields(vd_addr vd_pr_list vd_pur_acct vd_pur_cc vd_pur_sub vd_type)
      where vd_addr = l_vd_addr
      no-lock:
   end. /* FOR FIRST vd_mstr */

END PROCEDURE. /* readvd_mstr */

PROCEDURE display_message_mfmsg01:

   define input        parameter l_msg_nbr   as   integer     no-undo.
   define input        parameter l_msg_level as   integer     no-undo.
   define input-output parameter l_confirm   like mfc_logical no-undo.

       {pxmsg.i &MSGNUM=l_msg_nbr &ERRORLEVEL=1 &CONFIRM=l_confirm}

END PROCEDURE. /* display_message_mfmsg01 */
